<template>
  <section class='f-order-detail'>
    <section class="f-goods-box">
      <p>{{ orderInfo.iccid || '--' }}</p>
      <section class="f-flex-between f-desc">
        <div>
          <p>{{orderInfo.packageName}}</p>
          <p class="f-mt-05" style="font-size: 10px;color: #666666;">数量：{{orderInfo.buyNum}}</p>
        </div>
        <img style="width: 42px;height: 42px;" src="@/assets/icons/icon_order.png" alt="">
      </section>
    </section>

    <ul class="f-list-box">
      <li>
        <p>系统订单号</p>
        <p>{{orderInfo.sysOrderId}}</p>
      </li>
      <li>
        <p>交易流水号</p>
        <p>{{orderInfo.payOrderId}}</p>
      </li>
      <li>
        <p>下单时间</p>
        <p>{{getDateTime(orderInfo.createTime)[6]}}</p>
      </li>
      <li>
        <p>支付方式</p>
        <p>{{orderInfo.payType == 2? '微信支付': orderInfo.payType == 3? '支付宝支付': '余额支付'}}</p>
      </li>
      <li>
        <p>支付时间</p>
        <p>{{getDateTime(orderInfo.payTime)[6]}}</p>
      </li>
      <li>
        <p>支付金额</p>
        <p style="color:#FF3F3F">¥ {{ (orderInfo.payMoney/100).toFixed(2) }}</p>
      </li>
    </ul>
  </section>
</template>

<script>
import { ref, reactive, toRefs, onMounted, watch } from 'vue';
import { useRouter, useRoute } from 'vue-router'
import { useStore } from 'vuex';
import { getDateTime } from '@/utils/utils';
import api from '../../api';

export default {
  setup(props, context) {
    const store = useStore()

    const router = useRouter()
    const route = useRoute();

    const state = reactive({
      orderInfo: {}
    })

    onMounted(() => {
      store.commit("setNavBar", {
        title: '订单详情',
        show: true,
        left: true,
        leftType: 'back',
        right: false,
        rightType: 'search',
        bg: '',
      });

      getYklOrderDetail()
    })

    const getYklOrderDetail = () => {
      api.yklCardOrderDetail({ sysOrderId: route.query.sysOrderId }).then(res => {
        state.orderInfo = res.data
      })
    }

    return {
      ...toRefs(state),
      getDateTime
    }
  }
}
</script>

<style lang='scss' scoped>
.f-order-detail {
  padding: 19px 14px;
  .f-goods-box {
    background: #ffffff;
    border-radius: 13px;
    font-weight: 400;
    font-size: 14px;
    color: #000000;
    padding: 18px 15px 23px 14px;
    margin-bottom: 14px;
    .f-desc {
      margin-top: 20px;
      font-weight: 400;
      font-size: 12px;
      color: #424242;
    }
  }
  .f-list-box {
    background: #ffffff;
    border-radius: 13px;
    font-weight: 300;
    font-size: 11px;
    color: #666666;
    padding: 18px 15px 23px 14px;
    li {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 30px;
      p:last-child {
        color: #000000;
      }
    }
  }
}
</style>